#pragma once

#include <algorithm/analytical_model/algorithm/cuda/receiver/Receiver.cuh>

#include <tuple>

namespace solar::cuda
{
    class RectangleReceiver : public Receiver
    {
        public:
            __device__ RectangleReceiver() = default;
            __host__ RectangleReceiver(cudaStream_t stream = nullptr);
            __device__ __host__ RectangleReceiver(const RectangleReceiver& rectangle_receiver);
            /// @returns {t, u, v, isIntersected}
            __device__ __host__ auto intersect(const float3& orig, const float3& dir)
                -> std::tuple<float, float, float, bool>;
            void init(float pixel_per_meter_for_receiver) override;
            void setResolution(float pixel_per_meter_for_receiver) override;
            void setFocusCenter();
            __host__ __device__ auto getFocusCenter(const float3& heliostat_position) -> float3 override;

            float3 rect_vertices_[4]{}; // Four vertexes of rectangle
            float3 local_normal_{};
            float3 focus_center_{};

        private:
            void initVertex();
            void setLocalNormal(); // Set local normal
            void setLocalVertex(); // Set local vertex
            void setWorldVertex(); // Set world vertex
    };
} // namespace solar::cuda
